﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Home.Master" AutoEventWireup="true" CodeBehind="ViewProject.aspx.cs" Inherits="TimeWork.ViewProject" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Bredcrumb_child" ContentPlaceHolderID="Bredcrumb" runat="server">
    <li><a href="#" class="report">Quản trị</a></li>>
    <li><a href="ProjectTree.aspx">Quản lý cây danh mục</a></li>>
    <li><a href="#">Chi tiết sản phẩm</a></li>
</asp:Content>
<asp:Content ID="MainContent_child" ContentPlaceHolderID="MainContent" runat="server">
    <form runat="server"> 
    <asp:ScriptManager ID="ScriptManager" runat="server">
    </asp:ScriptManager>
    <div class="content-project">
        <div class="left-content-project">
            <div class="project">
            <table>
                <tr>
                    <th class="header" colspan="2">Sản phẩm</th>
                </tr>
                <tr><td colspan="2" align="center">
                    <asp:Label ID="lblError" runat="server" CssClass="fail"></asp:Label>
                    </td></tr>
                <tr>
                    <td style="width:90px;">Tên sản phẩm*:</td>
                    <td>
                        <asp:TextBox ID="txtProjectName" runat="server" Width="280px"></asp:TextBox> 
                    </td>
                </tr>
                <tr>
                    <td>Người chủ trì*:</td>
                    <td>
                        <asp:DropDownList ID="ddlProjectManager" runat="server">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
            <!-- Bo sung thong tin tuy chon -->
            <table>
                <tr>
                    <td>
                        <asp:Panel ID="PanelHide" runat="server">
                            <strong>Thông tin bổ sung</strong> &nbsp;&nbsp;<asp:Label ID="lblText" runat="server"></asp:Label>&nbsp;&nbsp;<asp:Image ID="imgPanel" runat="server" />
                        </asp:Panel>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Panel ID="PanelShow" runat="server">
                            <div class="insert-item-express">
                                <table class="item-express">
                                    <tr>
                                        <td style="width:150px;" class="tdLabel">
                                            Đối tác:
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlClient" runat="server">
                                            </asp:DropDownList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  class="tdLabel">
                                            Mô tả sản phẩm:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" 
                                                Height="81px" Width="210px"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  class="tdLabel">
                                            Chỉ hiện sản phẩm này với thành viên?
                                        </td>
                                        <td>
                                            <asp:CheckBox ID="cbIsMember" runat="server" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  class="tdLabel">
                                            Sản phẩm đã hoàn thành?
                                        </td>
                                        <td>
                                            <asp:CheckBox ID="cbIsComplete" runat="server" />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  class="tdLabel"> 
                                            Ngày bắt đầu:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtStartDay" runat="server"></asp:TextBox>&nbsp;<asp:Image ID="imgStartDate" runat="server" ImageUrl="~/resources/img/icons/calendar.png" />&nbsp;
                                            <asp:CalendarExtender ID="CalendarExtender" runat="server" 
                                                PopupPosition="BottomLeft" PopupButtonID="imgStartDate" 
                                                TargetControlID="txtStartDay" Format="dd/MM/yyyy">
                                            </asp:CalendarExtender>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  class="tdLabel">
                                            Ngày kết thúc:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtEndDay" runat="server"></asp:TextBox>&nbsp;<asp:Image ID="imdEndDate" runat="server" ImageUrl="~/resources/img/icons/calendar.png" />&nbsp;
                                            <asp:CalendarExtender ID="CalendarExtender1" runat="server" 
                                                PopupPosition="BottomLeft" PopupButtonID="imdEndDate" 
                                                TargetControlID="txtEndDay" Format="dd/MM/yyyy">
                                            </asp:CalendarExtender>
                                        </td>
                                    </tr>
                                </table>                                
                            </div>
                        </asp:Panel>
                    </td>
                </tr>
            </table>
            <table class="item-express">
                <tr>
                    <td style="text-align: right;">
                        <asp:Button ID="btnCreateProject" runat="server" Text="Tạo mới sản phẩm" 
                            CssClass="mybutton" onclick="btnCreateProject_Click" 
                            ValidationGroup="Project" />
                        <asp:Button ID="btnDelete" runat="server" Text="Xóa" 
                            CssClass="mybutton color-red" onclick="btnDelete_Click" 
                            OnClientClick="return confirm('Bạn chắc chắn muốn xóa sản phẩm này?\nThao tác này cũng xóa luôn toàn bộ các thông tin đăng ký thời gian của nhân viên trên sản phẩm này.\nHãy cẩn thận!');" 
                            ValidationGroup="Project"/>&nbsp;&nbsp;&nbsp;<asp:Button 
                            ID="btnUpdate" runat="server" Text="Cập nhật" CssClass="mybutton" 
                            Visible="False" onclick="btnUpdate_Click" ValidationGroup="Project" />
                    </td>
                </tr>
            </table>
            </div><!-- End .project -->
            <br /><br />
            <asp:Panel ID="pnlActivity" runat="server">
                <div class="project activity">
                    <table>
                        <tr>
                            <th class="header" colspan="2">Công việc</th>
                        </tr>
                        <tr><td colspan="2">&nbsp;</td></tr>
                        <tr>
                            <td colspan="2">
                                <!--Load bang du lieu-->
                                <asp:GridView ID="grvActivity" runat="server" AutoGenerateColumns="False" 
                                    DataKeyNames="ActivityID" onrowdatabound="grvActivity_RowDataBound" 
                                    ShowFooter="True" onrowcommand="grvActivity_RowCommand">
                                    <RowStyle CssClass="RowStyle" />

                                    <Columns>
                                        <asp:TemplateField HeaderText="Mã" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91" ItemStyle-Width="60px">
                                            <ItemTemplate>
                                                <asp:Label ID="lblCode" runat="server" Text='<%# Eval("ActivityCode") %>' Font-Bold="True"></asp:Label>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                <asp:Label ID="lblText" runat="server" Text='Tổng' Font-Bold="True" ForeColor="#990000"></asp:Label>
                                            </FooterTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Tên công việc" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91" ItemStyle-Width="145px">
                                            <ItemTemplate>
                                                <a href="ViewActivity.aspx?aid=<%# Eval("ActivityID") %>"><%# Eval("ActivityName") %></a>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <%--<asp:TemplateField HeaderText="Loại thời giờ" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91">
                                            <ItemTemplate>
                                                <asp:Label ID="lblTypeTime" runat="server" Text='<%# Eval("TypeTimeName") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>--%>
                                        <asp:TemplateField HeaderText="TG dự kiến" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:Label ID="lblEstimateTime" runat="server" Text='<%# Eval("ActivityEstimateTime") %>'></asp:Label>h
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                <asp:Label ID="lblSumEstimateTime" runat="server" Font-Bold="True" ForeColor="#990000"></asp:Label>
                                            </FooterTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="TG thực tế" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:Label ID="lblHour" runat="server" Text='<%# Eval("Hour") %>'></asp:Label>:<asp:Label ID="lblMinute" runat="server" Text='<%# Eval("Minute") %>'></asp:Label> h
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                <asp:Label ID="lblSum" runat="server" Font-Bold="True" ForeColor="#990000"></asp:Label>
                                            </FooterTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ShowHeader="false" HeaderStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91" ItemStyle-Width="45px">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="imgUp" runat="server" ImageUrl="~/resources/img/icons/up.png" CssClass="input-image" CausesValidation="False" CommandName="UpLevel" CommandArgument='<%# Eval("ActivityID") %>' /><asp:ImageButton ID="imgDown" runat="server" ImageUrl="~/resources/img/icons/down.png" CssClass="input-image" CausesValidation="False" CommandName="DownLevel" CommandArgument='<%# Eval("ActivityID") %>' />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr>
                            <td style="width:150px;"  class="tdLabel">Mã công việc:</td>
                            <td>
                                <asp:TextBox ID="txtActivityCode" runat="server" Width="100px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width:150px;"  class="tdLabel">Tên công việc*:</td>
                            <td>
                                <asp:TextBox ID="txtActivityName" runat="server" Width="200px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rqActivityName" runat="server" ErrorMessage="*" ControlToValidate="txtActivityName" ValidationGroup="Activity"></asp:RequiredFieldValidator>
                            </td>
                        </tr>

                        <tr>
                            <td class="tdLabel">Thời gian dự kiến*:</td>
                            <td>
                                <asp:TextBox ID="txtEstimateTime" runat="server" Width="80px"></asp:TextBox>&nbsp;&nbsp;<i>(tính bằng giờ)</i>
                                <asp:RangeValidator ID="rqEstimateTime" runat="server" ErrorMessage="*" ControlToValidate="txtEstimateTime" ValidationGroup="Activity" Type="Integer" MinimumValue="0" MaximumValue="999999"></asp:RangeValidator>
                            </td>
                        </tr>
                        <%--<tr>
                            <td  class="tdLabel">Loại thời gian*:</td>
                            <td>
                                <asp:DropDownList ID="ddlTypeTime" runat="server">
                                </asp:DropDownList>
                            </td>
                        </tr>--%>
                        <tr>
                            <td style="text-align: right;" colspan="2">
                                <asp:Button ID="btnCreate" runat="server" Text="Tạo mới" CssClass="mybutton" 
                                    onclick="btnCreate_Click" ValidationGroup="Activity" />&nbsp;&nbsp;&nbsp;
                                    <%--<asp:Button ID="btnCopy" runat="server" Text="Sao chép" 
                                    CssClass="mybutton color-yellow" CausesValidation="False" 
                                    onclientclick="show()" />--%>
                                    <input type="button" id="btnCopy" value="Sao chép" class="mybutton color-yellow" onclick="show('true');" />
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;" colspan="2">
                                <asp:Label ID="lblNoActivities" runat="server" CssClass="error" Text="Lưu ý: Để nhân viên có thể đăng ký thời gian làm việc, bạn cần bổ sung các công việc vào sản phẩm tương ứng."></asp:Label>
                            </td>
                        </tr>
                    </table> 
                </div>
            </asp:Panel>
        </div>

        <div class="right-content-project">
            <asp:Panel ID="pnlProjectMember" runat="server">
                <div class="project-member">
                    <table>
                        <tr><th class="header" colspan="2">Thành viên</th></tr>
                        <tr><td colspan="2">&nbsp;</td></tr>
                        <tr>
                            <td colspan="2">
                                <asp:GridView ID="gvProjectMember" runat="server" AutoGenerateColumns="False" 
                                    DataKeyNames="SPStaffID,SPProjectID,SPCostPerHour" onrowcancelingedit="gvProjectMember_RowCancelingEdit" 
                                    onrowdatabound="gvProjectMember_RowDataBound" 
                                    onrowdeleting="gvProjectMember_RowDeleting" 
                                    onrowediting="gvProjectMember_RowEditing" 
                                    onrowupdating="gvProjectMember_RowUpdating">
                                    <Columns>
                                        <asp:TemplateField HeaderText="Họ tên" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91">
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblStaffName" Text='<%# Eval("StaffName") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Lương theo giờ" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91">
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblCostPerHour" Text='<%# Eval("SPCostPerHour") %>'></asp:Label> VND
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:TextBox ID="txtCostPerHour" runat="server"></asp:TextBox>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#f3f9ff">
                                            <EditItemTemplate>
                                                <asp:ImageButton ID="imgUpdate" runat="server" CausesValidation="false" CommandName="Update" ImageUrl="~/resources/img/icons/update.png"  ToolTip="Cập nhật" CssClass="wrap_input"></asp:ImageButton>
                                                <asp:ImageButton ID="imgCancel" runat="server" CausesValidation="false" CommandName="Cancel" ImageUrl="~/resources/img/icons/cancel.png"  ToolTip="Hủy" CssClass="wrap_input"></asp:ImageButton>
                                            </EditItemTemplate>
                                            <ItemTemplate>
                                                <asp:ImageButton ID="imgEdit" runat="server" CausesValidation="false" CommandName="Edit" ImageUrl="~/resources/img/icons/page_white_edit.png" ToolTip="Sửa" CssClass="wrap_input"></asp:ImageButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left" HeaderStyle-BackColor="#f3f9ff">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete" ImageUrl="~/resources/img/icons/delete.png"  ToolTip="Xóa" CssClass="wrap_input" OnClientClick="return confirm('Bạn chắc chắn muốn xóa người dùng này khỏi danh sách thành viên?');"></asp:ImageButton>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                        <tr><td colspan="2">&nbsp;</td></tr>
                        <tr>
                            <td class="tdLabel">Họ tên:</td>
                            <td> 
                                <asp:DropDownList ID="ddlMember" runat="server">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td  class="tdLabel">Lương theo giờ:</td>
                            <td><asp:TextBox ID="txtCost" runat="server" Width="64px"></asp:TextBox> VND <asp:RangeValidator 
                                    ID="rqCost" runat="server" ErrorMessage="*" ControlToValidate="txtCost" 
                                    Type="Double" MinimumValue="0" MaximumValue="9999999999" 
                                    ValidationGroup="Member" ForeColor="Red"></asp:RangeValidator></td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right"><asp:Button ID="btnAddMember" runat="server" 
                                    Text="Thêm mới" CssClass="mybutton" ValidationGroup="Member" 
                                    onclick="btnAddMember_Click" /></td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
            <br /><br />
            <asp:Panel ID="pnlReportTime" runat="server">
                <div class="project-member">
                    <table>
                        <tr><th class="header" colspan="2">Thời gian thực tế</th></tr>
                        <tr>
                            <td colspan="2">
                                <asp:GridView ID="gvReportTime" runat="server" AutoGenerateColumns="False" DataKeyNames="SAStaffID">
                                    <Columns>
                                        <asp:TemplateField HeaderText="Họ tên" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91">
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblStaffNameTime" Text='<%# Eval("StaffName") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Thời gian" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="#f3f9ff" HeaderStyle-ForeColor="#375b91" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:Label runat="server" ID="lblTimeReportHour" Text='<%# Eval("SumHour") %>'></asp:Label>:<asp:Label runat="server" ID="lblTimeReportMinute" Text='<%# Eval("SumMinute") %>'></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </td>
                        </tr>
                    </table>
                </div>
            </asp:Panel>
            <br /><br />
            <div class="project-member" style="text-align: center;border: none;">
                <asp:Image ID="imgChartAccu" runat="server" />
            </div>
        </div>

        <div id="popup">
            <asp:Panel ID="pnlCopy" runat="server">
            <div class="info-box" style="width:auto; background: #ffffff;">
                <h3>Sao chép công việc</h3>
                <table>
                    <tr>
                        <td>Sao chép công việc từ sản phẩm: </td>
                        
                        <td>
                            <asp:DropDownList ID="ddlCopyProject" runat="server">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="right">
                            <asp:Button ID="btnCopyActivity" runat="server" Text="Chấp nhận" 
                                CssClass="mybutton" CausesValidation="False" onclick="btnCopyActivity_Click" />&nbsp<asp:Button 
                                ID="btnCancelCopy" runat="server" Text="Hủy" CssClass="mybutton color-yellow" 
                                onclick="btnCancelCopy_Click" OnClientClick="show('false')" CausesValidation="False" /></td>
                    </tr>
                </table>
            </div>
            </asp:Panel>
        </div>
    </div>

<asp:CollapsiblePanelExtender 
        ID="CollapsiblePanelExtender" 
        runat="server"
        CollapseControlID="PanelHide"
        Collapsed="true"
        ExpandControlID="PanelHide"
        TextLabelID="lblText"
        CollapsedText="Hiện chi tiết"
        ExpandedText="Ẩn chi tiết"
        CollapsedImage="~/resources/img/icons/expand.gif"
        ExpandedImage="~/resources/img/icons/collapse.gif"
        ImageControlID="imgPanel"
        ExpandDirection="Vertical"
        TargetControlID="PanelShow"
        ScrollContents="false">
    </asp:CollapsiblePanelExtender>
</form>
<script type="text/javascript">
    function show(xxx) {
        var x = document.getElementById("popup");
        if (xxx) {
            x.style.display = "block";
        } else {
            x.style.display = "none";
        }
    }
</script>
</asp:Content>
